﻿// -------------------------------------------------------------------------
//    @FileName         :    NFLevelPart.cpp
//    @Author           :    gaoyi
//    @Date             :    2025/1/4
//    @Email            :    445267987@qq.com
//    @Module           :    NFLevelPart
//
// -------------------------------------------------------------------------

#include "NFLevelPart.h"

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFLevelPart::NFLevelPart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFLevelPart::~NFLevelPart()
{
}

int NFLevelPart::CreateInit()
{
    return 0;
}

int NFLevelPart::ResumeInit()
{
    return 0;
}

int NFLevelPart::LoadFromDB(const proto_ff::tbRoleDetail* pDBData)
{
    m_stChapterScoreData.FromPb(pDBData->role_play_data().charpter_score());
    for (int i = 0; i < (int)m_stChapterScoreData.chapter_score_list.size(); i++)
    {
        m_charpterCompleteFlags.SetBit(m_stChapterScoreData.chapter_score_list[i].chapter_id);
    }

    for(int i = 0; i < (int)m_stChapterScoreData.instance_score_list.size(); ++i)
    {
        m_instanceCompleteFlags.SetBit(m_stChapterScoreData.instance_score_list[i].instance_id);
    }
    return 0;
}

int NFLevelPart::InitConfig(proto_ff::tbRoleDetail* pDbData, const RoleOne& stRoleOne)
{
    return 0;
}

int NFLevelPart::SaveDB(proto_ff::tbRoleDetail* pDBData)
{
    m_stChapterScoreData.ToPb(pDBData->mutable_role_play_data()->mutable_charpter_score());
    return 0;
}

int NFLevelPart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stChapterScoreData.ToPb(pCSGetRoleRsp->mutable_chapter_score_data());
    return 0;
}

int NFLevelPart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
